package com.eu.ebpm.engine.cmd.pvm;

import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.eu.ebpm.engine.cmd.TaskIdentitySupport;
import com.eu.ebpm.engine.entity.deploy.Mission;
import com.eu.ebpm.engine.entity.enumm.TaskStatus;
import com.eu.ebpm.engine.entity.history.HisTask;
import com.eu.ebpm.engine.entity.runtime.TaskEntity;
import com.eu.ebpm.engine.repository.HisTaskRepository;
import com.eu.ebpm.engine.repository.TaskRepository;

/**
 * 
 * @author 王晓华
 */
@Component
public class LaneTaskIntoCommand {

	@Autowired
	protected TaskIdentitySupport taskIdentityService;
	@Autowired
	private TaskRepository taskRepository;
	@Autowired
	private HisTaskRepository hisTaskRepository;
	
	public void execute(Mission m, TaskEntity task, Map<String, Object> variables) {
		TaskEntity laneTask = new TaskEntity(m.getName(), m.getDesc(), task.getAssignee(),  new Date(), new Date(), task.getExecutionId(), task.getRootExecutionId(), m.getId());
		taskRepository.insert(laneTask);
		//插入历史表
		hisTaskRepository.insert(new HisTask(laneTask.getId(), m.getType(), m.getName(), m.getDesc(), null, task.getExecutionId(), task.getRootExecutionId(), laneTask.getMissionId(), laneTask.getAssignee(), laneTask.getAssigneeTime(), laneTask.getCreateTime(), null, laneTask.getRemark(), TaskStatus.EXEING.getCode()));
	}
	
	
	
	
	

}
